<template>
    <div>
        <span>请选择要下载的文件</span>
        <el-table
                :data="fileList"
                style="width: 100%">
            <el-table-column
                    prop="fileName"
                    label="文件名"
                    width="180">
            </el-table-column>
            <el-table-column
                    v-if="show"
                    prop="fileUrl"
                    label="文件链接"
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="type"
                    label="文件类型"
                    width="180">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                            type="primary"
                            size="mini"
                            @click="handleEdit(scope.row)">下载</el-button>

                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>

export default {
    name: "file",
    data () {
        return {
            fileList:[],
            show: false
        }
    },
    created() {
        this.getFileList();
    },
    methods:{
        handleEdit(row){
            let url = row.fileUrl;
            window.open("http://"+url);
        },
        getFileList(){
            var vm = this;
            this.axios({
                url: '/myapi/Qiniu/fileList',
                method: 'get'
            }).then(function (response) {
                if(response.data.success === true){
                    vm.fileList = response.data.content;
                    console.log(vm.fileList);
                }
                else {
                    console.log(response.data);
                    vm.$message.error('获取文件列表失败');
                }
            });
        }
    }
}
</script>

<style scoped>

</style>
